package com.logicalthinking.socialmall.common.vo.requestVo.role;

import com.github.chenlijia1111.utils.core.StringUtils;
import com.logicalthinking.socialmall.common.enums.AuthEnum;
import com.logicalthinking.socialmall.common.vo.requestVo.PageAbleVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import java.util.Objects;

/**
 * 角色分页查询参数
 *
 * @author Chen LiJia
 * @since 2020/2/17
 */
@ApiModel
@Setter
@Getter
public class RolePageQueryParams extends PageAbleVo {

    /**
     * 角色名称
     */
    @ApiModelProperty(value = "角色名称")
    private String roleName;

    /**
     * 权限名称
     */
    @ApiModelProperty(value = "权限名称")
    private String authName;

    /**
     * 权限值
     */
    private Integer authType;

    public void setAuthName(String authName) {
        this.authName = authName;
        //查找权限对应的权限值
        if (StringUtils.isNotEmpty(authName)) {
            AuthEnum authEnum = AuthEnum.authNameTransferToAuthEnum(authName);
            if (Objects.nonNull(authEnum)) {
                this.authType = authEnum.getAuthType();
            }
        }
    }
}
